<?php
require_once 'libs/Config.php';
$Config=new Config();
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="assets/css/base.css" type="text/css" />
    <title>创建门店</title>
</head>
<body>
<form action="libs/CreateShop.php" method="post">
    <div class="input-container">
        <label>外部门店编号：</label>
        <input type="text" name="store_id" value="hpj001">
        <span>最长32位字符，该编号将作为收单接口的入参， 请开发者自行确保其唯一性</span>
    </div>
    <div class="input-container">
        <label>类目id：</label>
        <input type="text" name="category_id" value="2016062900190249">
        <span>请参考<a href="https://docs.open.alipay.com/205/104497" target="_blank">商户入驻要求</a></span>
    </div>
    <div class="input-container">
        <label>品牌LOGO：</label>
        <input type="file" onchange="uploadImage(this,'brand_logo')">
        <input type="hidden" name="brand_logo" value="">
    </div>
    <div class="input-container">
        <label>主门店名：</label>
        <input type="text" name="main_shop_name" value="蛋茉EggMo" placeholder="比如：肯德基">
    </div>
    <div class="input-container">
        <label>省份编码：</label>
        <input type="text" name="province_code" value="500000" placeholder="重庆">
        <span>请参考<a href="https://gw.alipayobjects.com/os/basement_prod/92d874c4-39a9-4977-b710-d55dad374b7f.csv" target="_blank">点此下载</a></span>
    </div>
    <div class="input-container">
        <label>城市编码：</label>
        <input type="text" name="city_code" value="500100" placeholder="重庆市">
        <span>请参考<a href="https://gw.alipayobjects.com/os/basement_prod/92d874c4-39a9-4977-b710-d55dad374b7f.csv" target="_blank">点此下载</a></span>
    </div>
    <div class="input-container">
        <label>区县编码：</label>
        <input type="text" name="district_code" value="500107" placeholder="九龙坡区">
        <span>请参考<a href="https://gw.alipayobjects.com/os/basement_prod/92d874c4-39a9-4977-b710-d55dad374b7f.csv" target="_blank">点此下载</a></span>
    </div>
    <div class="input-container">
        <label>门店详细地址：</label>
        <textarea name="address" placeholder="注：不含省市区。例：人民东路18号">奥体东路1号21-16</textarea>
    </div>
    <div class="input-container">
        <label>经度：</label>
        <input type="text" name="longitude" value="106.510622" placeholder="最长15位字符（包括小数点）">
        <span>高德经纬度查询：<a href="http://lbs.amap.com/console/show/picker" target="_blank">http://lbs.amap.com/console/show/picker</a></span>
    </div>
    <div class="input-container">
        <label>纬度：</label>
        <input type="text" name="latitude" value="29.525106" placeholder="最长15位字符（包括小数点）">
        <span>高德经纬度查询：<a href="http://lbs.amap.com/console/show/picker" target="_blank">http://lbs.amap.com/console/show/picker</a></span>
    </div>
    <div class="input-container">
        <label>门店电话号码：</label>
        <input type="text" name="contact_number" value="023-81370275" placeholder="门店电话号码；支持座机和手机，只支持数字和+-号">
    </div>
    <div class="input-container">
        <label>门店首图：</label>
        <input type="file" onchange="uploadImage(this,'main_image')">
        <input type="hidden" name="main_image" value="">
        <span>推荐尺寸2000*1500</span>
    </div>
    <div class="input-container">
        <label>门头照片：</label>
        <input type="file" onchange="uploadImage(this,'audit_images')">
    </div>
    <div class="input-container">
        <label>内景照片1：</label>
        <input type="file" onchange="uploadImage(this,'audit_images')">
    </div>
    <div class="input-container">
        <label>内景照片2：</label>
        <input type="file" onchange="uploadImage(this,'audit_images')">
    </div>
    <input type="hidden" name="audit_images" value="">
    <div class="input-container">
        <label>ISV返佣id：</label>
        <input type="text" name="isv_uid" value="<?php echo $Config->partner_id;?>">
        <span>此字段必须是个合法uid，2088开头的16位支付宝会员账号</span>
    </div>
    <div class="input-container">
        <label>门店营业执照图片：</label>
        <input type="file" onchange="uploadImage(this,'licence')">
        <input type="hidden" name="licence" value="">
    </div>
    <div class="input-container">
        <label>门店营业执照编号：</label>
        <input type="text" name="licence_code" value="91500107MA5U7F0G3K">
    </div>
    <div class="input-container">
        <label>门店营业执照名称：</label>
        <input type="text" name="licence_name" value="重庆风起溪文化传播有限公司">
    </div>
    <div class="input-container">
        <label>营业执照过期时间：</label>
        <input type="text" name="licence_expires" value="长期">
    </div>
    <div class="input-container">
        <label>门店授权函：</label>
        <input type="file" onchange="uploadImage(this,'auth_letter')">
        <input type="hidden" name="auth_letter" value="">
    </div>
    <div class="input-container">
        <label>request_id：</label>
        <input type="text" name="request_id" value="<?php echo time();?>">
        <span>支持英文字母和数字，由开发者自行定义（不允许重复），在门店notify消息中也会带有该参数，以此标明本次notify消息是对哪个请求的回应。</span>
    </div>
    <div class="input-container">
        <label>店铺接口业务版本号：</label>
        <input type="text" name="biz_version" value="2.0">
    </div>
    <input type="submit" value="提交">
</form>
</body>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="assets/js/upload_image.js"></script>
<script type="text/javascript">
    function uploadImage(obj,name) {
        var formData = new FormData();
        formData.append("file", $(obj).get(0).files[0]);
        window.UploadImage({
            url:"libs/UploadImage.php",
            data:formData,
            callback:function (info) {
                info=JSON.parse(info);
                console.log(info);
                if(info.errorCode===0){
                    if(name!=='audit_images'){
                        $('input[name="'+name+'"]').val(info.data.image_id);
                    }else {
                        let image_ids=$('input[name="'+name+'"]').val();
                        if(image_ids.length>0){
                            image_ids+=','+info.data.image_id;
                        }else {
                            image_ids=info.data.image_id;
                        }
                        $('input[name="'+name+'"]').val(image_ids);
                    }
                }
                alert(info.msg);
            }
        });
    }
</script>
</html>